package com.rocbrid.order.feign;

import com.rocbrid.order.feign.fallback.ProductFeignClientFallback;
import com.rocbrid.product.bean.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;

@FeignClient(value = "service-product",fallback = ProductFeignClientFallback.class)
/**
 * feign客户端,vlue直接设置远程调用微服务的名称,
 feign自己链接注册中心,在service-product名字下面自己负载均衡的选择一个进行发送请求
 */
public interface ProductFeignClient {

    //mvc注解的两套使逻辑
    //1.标注在controller上,是接受这样的请求
    //2.标注在FeignClient上,是发送这样的请求
    //将请求到的数据封装成Product
    @GetMapping("/product/{id}")
   Product getProduct(@PathVariable("id") Long prductId);

   /* @GetMapping("/product/{id}")
    void getProductWithToken(@PathVariable("id") Long prductId, @RequestHeader("token") String token );*/
}
